import { createRouter, createWebHashHistory } from 'vue-router';

const routes = import.meta.glob('@/views/**/index.vue');
const pages = Object.keys(routes).map((route) => {
  const name = route.split('/')[3];
  return {
    path: `/${name}`,
    component: routes[route],
    name,
  };
});

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: '/useIntersectionObserver',
    },
    ...pages,
  ],
});

export default router;
